package com.daoImpl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.dao.FunctionDao;
import com.domain.Function;

import dao.base.BaseDaoImpl;


@Repository(value="functionDao")
public class FunctionDaoImpl extends BaseDaoImpl<Function> implements FunctionDao{

	/**
	 * 根据用户id查询对应的权限.users---role---function
	 */
	@Override
	public List<Function> findByUserId(String id) {
		String hql = "from Function f left outer join fetch " +
				"f.roles r left outer join fetch r.users u where u.id = ?" + 
				"and f.generatemenu ='1' order by f.zindex desc";
		return (List<Function>) this.getHibernateTemplate().find(hql, id);
	}
}
